<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>UGC视频管理系统</title>
<link rel="stylesheet" href="images/template.css" />
</head>
<body>
<div class="wrap list" id="tabs_div">
<div class="header"><span class="close" id="winCloseButton">关闭</span>
<span class="user" id="username"><b id="uname"></b> <a href="#"
    id="loginoutbutton">退出</a> </span>
<div class="h_tt">UGC视频管理系统</div>
</div>
<div class="content clearfix" id="tabs">
<ul class="tabs clearfix">
    <li id="tabsLi-1" class="cur"><a
        href="javascript:tabClick('tabsName-1');" id="tabsName-1">当前页视频</a></li>
    <li id="tabsLi-2"><a href="javascript:tabClick('tabsName-2');"
        id="tabsName-2">批量框选</a></li>
    <li id="tabsLi-3"><a href="javascript:tabClick('tabsName-3');"
        id="tabsName-3">发布设置</a></li>
    <li id="tabsLi-4"><a href="javascript:tabClick('tabsName-4');"
        id="tabsName-4">历史记录</a></li>
</ul>
<!-- 当前页视频 start -->
<div id="tabs-1">
<form name="addForm">
<table class="tbl">
    <tr>
        <td colspan="3"><label for="">标题：<input type="text"
            class="inp1" id="title" name="title" /></label></td>
    </tr>
    <tr>
        <td colspan="3"><label for="">标签：<input type="text"
            class="inp1" id="tag" name="tag" /></label></td>
    </tr>
    <tr>
        <td class="tcol1"><span>分类：</span> <select id="cat_id"
            name="cat_id">
            <option value="员工">员工</option>
            <option value="用户">用户</option>
        </select></td>
        <td rowspan="3">遮标：</td>
        <td rowspan="3">
        <table class="tbl zheb">
            <tr>
                <td><input type="checkbox" class="cover"
                    name="cover" value="左上" /><label for="">左上</label></td>
                <td><input type="checkbox" class="cover"
                    name="cover" value="居上" /><label for="">居上</label></td>
                <td><input type="checkbox" class="cover"
                    name="cover" value="右上" /><label for="">右上</label></td>
            </tr>
            <tr>
                <td><input type="checkbox" class="cover"
                    name="cover" value="左中" /><label for="">左中</label></td>
                <td><input type="checkbox" class="cover"
                    name="cover" value="居中" /><label for="">居中</label></td>
                <td><input type="checkbox" class="cover"
                    name="cover" value="右中" /><label for="">右中</label></td>
            </tr>
            <tr>
                <td><input type="checkbox" class="cover"
                    name="cover" value="左下" /><label for="">左下</label></td>
                <td><input type="checkbox" class="cover"
                    name="cover" value="居下" /><label for="">居下</label></td>
                <td><input type="checkbox" class="cover"
                    name="cover" value="右下" /><label for="">右下</label></td>
            </tr>
        </table>
        </td>
    </tr>
    <tr>
        <td><span>马甲：</span> <select id="repeat_id"
            name="repeat_id">
            <option value="0">马甲</option>
        </select></td>
    </tr>
    <tr>
        <td><span>合作伙伴：</span> <select id="partner_id"
            name="partner_id">
            <option value="0">合作伙伴</option>
        </select></td>
    </tr>
    <tr>
        <td colspan="3"><label for="">专辑id：<input
            type="text" class="inp" id="album_id" name="album_id" /></label><label
            for="">专题id：<input type="text" class="inp"
            id="special_id" name="special_id" /></label></td>
    </tr>
    <tr>
        <td colspan="3" class="tcol2"><span>简介：</span> <textarea
            id="intro" name="intro"></textarea> <input type="hidden"
            class="inp1" id="url" name="url" /></td>
    </tr>
</table>
</form>
<div class="info"><!-- p>说明：此处设置的内容，将成为浏览器插件版抓取内容时默认填写的信息。需要修改密码，或是对马甲库、合作伙伴等进行更高等级的管理，请登录运营平台进行操作。</p-->
</div>
<div class="fbt"><a href="javascript:add();" id="addbutton" class="bt1">确定</a> <a
    href="#" id="addcancelbutton" class="bt2" />取消</a></div>
</div>
<!-- 当前页视频 end --> </div>
</div>
<!-- ajax start -->
<OBJECT ID="Calc" CLASSID="CLSID:2FD78431-E0CC-4CFB-99FD-8F8471F8A337"></OBJECT>
<!-- ajax end -->
<script>
/*
var xmlhttp;
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp = new XMLHttpRequest();
} else {// code for IE6, IE5
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
*/

function getuserinfo() {
    alert("getuserinfo");

    var calc = document.getElementById('Calc');
    result = calc.GET("http://api.cntv.cn/client/getuserinfo");
    alert(result); //返回-1是其他错误; 返回-2是C:\\WINDOWS\\system32\\drivers\\etc\\hosts不可读; 返回-3是api.cntv.cn不通
    if(result==200) {
        alert(calc.GetResponse());
        var username = '';
        // var json = JSON.parse(xmlhttp.responseText);
        var json = eval("(" + calc.GetResponse() + ")");
        username = json.username;
        alert(username);
        
        if (typeof (username) == "undefined" || username == "") {
            window.open("login.html","mainwin");
        } else {
            //window.open("add.html","mainwin");
        }
    }
    
    /*
    var str = "";
    //xmlhttp.onreadystatechange = getuserinfoCallback;
    xmlhttp.open("GET", "http://api.cntv.cn/client/getuserinfo", false);
    xmlhttp.setRequestHeader("Content-Type",
            "application/x-www-form-urlencoded");
    xmlhttp.send(str);
    getuserinfoCallback();
    */

}
/*
 * 取得用户信息回调
 */
function getuserinfoCallback() {
    alert("getuserinfoCallback");
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
        alert(xmlhttp.responseText);
        
        var username = '';
        // var json = JSON.parse(xmlhttp.responseText);
        var json = eval("(" + xmlhttp.responseText + ")");
        username = json.username;
        alert(username);
        
        if (typeof (username) == "undefined" || username == "") {
        	window.open("login.html","mainwin");
        } else {
            //window.open("add.html","mainwin");
        }
        
    }
}

getuserinfo();


/*
 * 单片添加
 */
function add() {
    var str = "";
    var elem = document.forms['addForm'].elements;
    for ( var i = 0; i < elem.length; i++) {
        if (i != 0)
            str += "&";
        str += elem[i].name + "=" + elem[i].value;
    }

    var calc = document.getElementById('Calc');
    var result = calc.POST("http://api.cntv.cn/client/add", str);
    // alert(result);
    // 返回-1是其他错误; 返回-2是C:\\WINDOWS\\system32\\drivers\\etc\\hosts不可读;
    // 返回-3是api.cntv.cn不通
    if (result == 200) {
        // alert(calc.GetResponse());
        // var json = eval('(' + calc.GetResponse() + ')');
        // var json = calc.GetResponse().parseJSON();
        var myJson = calc.GetResponse();
        var json = eval("(" + myJson + ")");
        alert(json.msg);
        location.reload();
    }

    /*
     * xmlhttp.onreadystatechange = addCallback; xmlhttp.open("POST",
     * "http://api.cntv.cn/client/add", false);
     * xmlhttp.setRequestHeader("Content-Type",
     * "application/x-www-form-urlencoded"); xmlhttp.send(str);
     */
}

/*
 * 单片提交页面
 */
function addTab() {
    // 转载本地存储到页面表单
    //alert(localData.getItem("title"));
    $("#title").val(localData.getItem("title"));

    $("#tag").val(localData.getItem("tag"));
    $("#intro").val(localData.getItem("intro"));

    cat_id_select = document.getElementById("cat_id");
    set_cat_id = localData.getItem("set_cat_id");
    for ( var i = 0; i < cat_id_select.options.length; i++) {
        if (cat_id_select.options[i].value == set_cat_id) {
            cat_id_select.options[i].selected = true;
        }
    }
    getrepeat();
    repeat_id_select = document.getElementById("repeat_id");
    for ( var i = 0; i < repeat_id_select.options.length; i++) {
        if (repeat_id_select.options[i].value == localData
                .getItem("set_repeat_id")) {
            repeat_id_select.options[i].selected = true;
        }
    }
    getpartner();
    partner_id_select = document.getElementById("partner_id");
    for ( var i = 0; i < partner_id_select.options.length; i++) {
        if (partner_id_select.options[i].value == localData
                .getItem("set_partner_id")) {
            partner_id_select.options[i].selected = true;
        }
    }
    cover_checkbox = document.getElementsByName("cover");
    // var coverAry = JSON.parse(localData.getItem("set_cover"));
    if (localData.getItem("set_cover") != null) {
        var coverAry = localData.getItem("set_cover").split(",");
        alert("test12");
        for ( var i = 0; i < cover_checkbox.length; i++) {
            for ( var j = 0; j < coverAry.length; j++) {
                if (cover_checkbox[i].value == coverAry[j]) {
                    cover_checkbox[i].checked = true;
                }
            }

        }
    }
    // $("#cover").val(localData.getItem("set_cover"));
    $("#album_id").val(localData.getItem("set_album_id"));
    $("#special_id").val(localData.getItem("set_special_id"));

    $("#url").val(localData.getItem("url"));
    $("#sendtype").val(localData.getItem("sendtype"));
    $("#format").val(localData.getItem("format"));

}
</script>
</body>
</html>
